<!--
 * @Description: 
 * @Author: wangqi
 * @Date: 2021-03-18 17:25:07
 * @LastEditTime: 2021-03-29 13:23:50
-->
<template>
	<div class="hellword">
		<h4>hello word! 《{{info}}》</h4>
		<template v-for="(img, index) in imgs">
			<img :src=img alt="" :key="index">
		</template>
	</div>
</template>
<style lang="less" scoped>
.hellword {
	h4 {
		color: red;
	}
}
</style>
<script>
// import { add } from '@/store/index.js'
export default {
	name: "helloWord",
	data() {
		return {
			info: "黃昏",
			robo: require('../assets/images/robo.png'),
			imgs: [],

		}
	},
	created() {
		const modulesFiles = require.context("../assets/images", false, /\.png$/);
		const requireAll = (req) => {
			return req.keys().map((modulePath, index) => {
				let moduleName = modulePath.match(/\.\/(.*)\.png/)
				return moduleName ? moduleName[1] : null
			})
		}
		const svgIcon = requireAll(modulesFiles);
		this.imgs = svgIcon.filter((imgName) => imgName).map((item) => { return require(`../assets/images/${item}.png`) });
		console.log(this.imgs, "svgIcon")
	},
}
</script>